package operation;

import book.Book;
import booklist.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-10
 * Time: 16:51
 */
public class Lendbook implements Operation {
    @Override
    public void work(BookList booklist) {
        System.out.println("借阅书籍");
        System.out.println("请输入你要借阅的书籍名称：");
        Scanner scan = new Scanner(System.in);
        String  name = scan.nextLine();
        int cursize = booklist.getBooksize();
        int i=0;
        for( ; i<cursize; i++) {
            Book book = booklist.getpos(i);
            if( book.getName().equals(name) ) {
                book.setIsborrow(true);
                System.out.println("借阅成功！");
                return ;
            }
        }
        System.out.println("要借阅书籍不存在");

    }
}
